package com.jiutong.meipengdai.http.model.requests;

import com.jiutong.meipengdai.http.RetrofitHandle;
import com.jiutong.meipengdai.http.SubscribeHandler;
import com.jiutong.meipengdai.http.model.services.MyAccountService;
import com.jiutong.meipengdai.http.subscribers.ProgressSubscriber;

import java.util.HashMap;
import java.util.Map;

import rx.Observable;
import rx.Subscriber;

/**
 * Created by suxi on 2017/6/1.
 */

public class MyAccountRequest extends SubscribeHandler {

    /**
     * 账户信息
     *
     * @param subscriber
     * @param fields
     */
    public void getAccountInfo(Subscriber subscriber, Map<String, Object> fields) {

        fields.put("method", "acct.info");
        fields.put("v", "2.0");
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(MyAccountService.class)
                .getAccountInfo(fields);
        toSubscribe(observable, subscriber);
    }

    /**
     * 账户设置
     *
     * @param subscriber
     * @param fields
     */
    public void getAccountSetting(Subscriber subscriber, Map<String, Object> fields) {

        fields.put("method", "safe.setting");
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(MyAccountService.class)
                .accountSetting(fields);
        toSubscribe(observable, subscriber);
    }




    /**
     * 银行卡列表
     *
     * @param subscriber
     * @param fields
     */
    public void getBanklist(Subscriber subscriber, Map<String, Object> fields) {

        fields.put("method", "pay.cardList");
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(MyAccountService.class)
                .getBanklist(fields);
        toSubscribe(observable, subscriber);
    }

    /**
     * 银行卡信息
     *
     * @param subscriber
     * @param fields
     */
    public void getBankInfo(Subscriber subscriber, Map<String, Object> fields) {

        fields.put("method", "acct.appBankInfo");
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(MyAccountService.class)
                .getBankInfo(fields);
        toSubscribe(observable, subscriber);
    }

    /**
     * 添加银行卡
     *
     * @param subscriber
     * @param fields
     */
    public void addBannkInfo(Subscriber subscriber, Map<String, Object> fields) {

        fields.put("method", "acct.addAppBankInfo");
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(MyAccountService.class)
                .addBannkInfo(fields);
        toSubscribe(observable, subscriber);
    }

    /**
     * 删除银行卡
     *
     * @param subscriber
     * @param fields
     */
    public void delBannkInfo(Subscriber subscriber, Map<String, Object> fields) {

        fields.put("method", "pay.unbindCard");
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(MyAccountService.class)
                .delBannkInfo(fields);
        toSubscribe(observable, subscriber);
    }

    /**
     * 消息中心
     *
     * @param subscriber
     * @param fields
     */
    public void getMsgCenter(Subscriber subscriber, Map<String, Object> fields) {

        fields.put("method", "acct.msgCenter");
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(MyAccountService.class)
                .msgCenter(fields);
        toSubscribe(observable, subscriber);
    }

    /**
     * 消息详情
     *
     * @param subscriber
     * @param fields
     */
    public void getMsgDetail(Subscriber subscriber, Map<String, Object> fields) {

        fields.put("method", "acct.msgDetail");
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(MyAccountService.class)
                .msgDetail(fields);
        toSubscribe(observable, subscriber);
    }

    /**
     * 还款记录
     *
     * @param subscriber
     * @param fields
     */
    public void getRepayRecord(Subscriber subscriber, Map<String, Object> fields) {

        fields.put("method", "acct.repayRecord");
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(MyAccountService.class)
                .getRepayRecord(fields);
        toSubscribe(observable, subscriber);
    }

    /**
     * 贷款记录
     *
     * @param subscriber
     * @param fields
     */
    public void getLoanRecord(Subscriber subscriber, Map<String, Object> fields) {

        fields.put("method", "acct.loanRecord");
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(MyAccountService.class)
                .getLoanRecord(fields);
        toSubscribe(observable, subscriber);
    }

    /**
     * 贷款详情
     *
     * @param subscriber
     * @param fields
     */
    public void getLoanInfo(Subscriber subscriber, Map<String, Object> fields) {

        fields.put("method", "acct.loanInfo");
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(MyAccountService.class)
                .getLoanInfo(fields);
        toSubscribe(observable, subscriber);
    }


    /**
     * 贷款操作记录
     *
     * @param subscriber
     * @param fields
     */
    public void getLoanoprRecord(Subscriber subscriber, Map<String, Object> fields) {

        fields.put("method", "acct.loanOprRecord");
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(MyAccountService.class)
                .getLoanoprRecord(fields);
        toSubscribe(observable, subscriber);
    }

    /**
     * 我的积分
     *
     * @param subscriber
     * @param fields
     */
    public void getScore(Subscriber subscriber, Map<String, Object> fields) {

        fields.put("method", "acct.score");
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(MyAccountService.class)
                .getScore(fields);
        toSubscribe(observable, subscriber);
    }

    /**
     * 收货地址
     */
    public void getAddress(Subscriber subscriber, Map<String, Object> fields) {
        fields.put("method", "safe.addressList");
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(MyAccountService.class)
                .getAddressList(fields);
        toSubscribe(observable, subscriber);

    }

    /**
     * 修改或删除地址
     *
     * @param progressSubscriber
     * @param fieldsMap
     */

    public void saveAddress(ProgressSubscriber progressSubscriber, HashMap<String, Object> fieldsMap) {
        fieldsMap.put("method", "safe.editAddress");
        handleFields(fieldsMap);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(MyAccountService.class)
                .saveAddress(fieldsMap);
        toSubscribe(observable, progressSubscriber);
    }

    /**
     * 添加新地址
     *
     * @param progressSubscriber
     * @param fieldsMap
     */

    public void saveNewAddress(ProgressSubscriber progressSubscriber, HashMap<String, Object> fieldsMap) {
        fieldsMap.put("method", "safe.addAddress");
        handleFields(fieldsMap);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(MyAccountService.class)
                .saveNewAddress(fieldsMap);
        toSubscribe(observable, progressSubscriber);
    }


    /**
     * 我的收款
     *
     * @param progressSubscriber
     * @param fieldsMap
     */

    public void getGatheringList(ProgressSubscriber progressSubscriber, HashMap<String, Object> fieldsMap) {
        fieldsMap.put("method", "loan.receivables");
        handleFields(fieldsMap);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(MyAccountService.class)
                .getGatheringList(fieldsMap);
        toSubscribe(observable, progressSubscriber);
    }
}
